package com.foo.designpattern.prototype;

import java.io.Serializable;

/**
 * com.foo.designpattern.prototype
 * Created with IntelliJ IDEA.
 * Created by jiang on 2016-04-26 23:52.
 *
 * @Description 齐天大圣的金箍棒
 * 金箍棒分别可以变大变小
 * 注意：本类里未对数值超出变量类型取值范围时的处理
 */
public class GoldRingedStaff implements Serializable {
    // 金箍棒的长度
    private float height = 100.0f;
    // 金箍棒的半径
    private float diameter = 10.0f;

    /**
     * 金箍棒变大：每次长度和半径分别增加一倍
     */
    public void grow() {
        this.height *= 2;
        this.diameter *= 2;
    }

    /**
     * 金箍棒缩小：每次长度和半径都减小一半
     */
    public void shrink() {
        this.height /= 2;
        this.diameter /= 2;
    }

    public float getHeight() {
        return height;
    }

    public float getDiameter() {
        return diameter;
    }
}
